import { defineStore } from 'pinia'

export default defineStore('global', {
  state: () => ({
    projectId: '',
    workspace: '',
    treeToTranslate: [] as MenuItem[]
  }),
  getters: {
    recordsPath: (state) => `${state.workspace}\\records`,
    treePath: (state) => `${state.workspace}\\records\\tree`,
    viewPath: (state) => `${state.workspace}\\src\\views`,
    originalFile: (state) => `original_tree_${state.projectId}.json`,
    updatedFile: (state) => `updated_tree_${state.projectId}.json`,
    translatedFile: (state) => `translated_tree_${state.projectId}.json`,
    dictionary: (state) => `dictionary_${state.projectId}.json`
  },
  persist: {
    enabled: true,
    strategies: [
      {
        key: 'project-config',
        storage: localStorage,
        paths: ['projectId', 'workspace']
      },
      {
        key: 'tree',
        storage: sessionStorage,
        paths: ['treeToTranslate']
      }
    ]
  }
})
